/**
    搭建 HTTP 服务.
    GET  /table  响应一个表格 4 行 3 列表格, 并实现隔行换色 (JS)
 */
require('http').createServer((request, response) => {
    //判断路径
    if(request.url === '/js/app.js'){
        //响应 app.js 文件中的内容
        response.end(require('fs').readFileSync('./js/app.js'));
    }else if(request.url === '/index.html'){
        //响应表格 
        response.end(`
            <!doctype html>
            <html>
                <head>
                    <style>
                        td{
                            width: 100px;
                            height: 50px;
                        }
                        table,td{
                            border-collapse: collapse;
                        }
                    </style>
                </head>
                <body>
                    <table border="1">
                        <tr>
                            <td></td><td></td><td></td>
                        </tr>
                        <tr>
                            <td></td><td></td><td></td>
                        </tr>
                        <tr>
                            <td></td><td></td><td></td>
                        </tr>
                        <tr>
                            <td></td><td></td><td></td>
                        </tr>
                    </table>
                    <!--作业-->
                    <script src="./js/app.js"></script>
                </body>
            </html>
        `);
    }else{
        response.statusCode = 404;
        response.end('<h1>404 Not Found</h1>');
    }
}).listen(80);

